/**
 * Copyright 2009 by Christian Scheid. This file is part of the switch eclipse plugin and is licensed under the GPL
 * version 3. Please refer to the URL http://www.gnu.org/licenses/gpl-3.0.html for details.
 */
package org.digitalsoul.switchplugin.actions;

import org.digitalsoul.switchplugin.model.ISwitchFile;
import org.digitalsoul.switchplugin.model.SwitchFile;

public class FilenameReplacementAction extends MatchReplacementAction {

    public FilenameReplacementAction(String matchRegex, String replacement) {
        super(matchRegex, replacement);
    }

    @Override
    public ActionType getType() {
        return ActionType.FILENAME_REPLACE;
    }

    @Override
    protected ISwitchFile applyToFile(ISwitchFile file, String string) {
        SwitchFile newFile = new SwitchFile(file);
        newFile.changeName(string);
        return newFile;
    }

    @Override
    protected String getFilePart(ISwitchFile file) {
        return file.getName();
    }
}
